const Sequelize = require('sequelize')
module.exports = (sequelize, DataTypes) => {
  return AclUserRole.init(sequelize, DataTypes)
}

class AclUserRole extends Sequelize.Model {
  static init(sequelize, DataTypes) {
    super.init(
      {
        id: {
          autoIncrement: true,
          type: DataTypes.INTEGER,
          allowNull: false,
          primaryKey: true,
        },
        userId: {
          type: DataTypes.INTEGER,
          allowNull: false,
          comment: '角色id',
          field: 'user_id',
        },
        roleId: {
          type: DataTypes.INTEGER,
          allowNull: false,
          comment: '权限id',
          field: 'role_id',
        },
      },
      {
        sequelize,
        tableName: 'acl_user_role',
        timestamps: false,
        underscored: true,
        indexes: [
          {
            name: 'PRIMARY',
            unique: true,
            using: 'BTREE',
            fields: [{ name: 'id' }],
          },
        ],
      },
    )
    return AclUserRole
  }
}
